package com.zhdl.modules.demo.dglProcess;

import com.zhdl.modules.demo.dglProcess.Robot.WorkPlace1RobotInterface;
import com.zhdl.modules.demo.dglProcess.camera.DGLCameraService;
import com.zhdl.modules.demo.testprocess.ChildOptImp;
import com.zhdl.modules.process.BaseProcess;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class WorkPlace1Process extends BaseProcess {
    @Resource
    DGLProcessInitService dglProcessInitService;
    @Resource
    WorkPlace1RobotInterface workPlace1RobotInterface;
    @Resource
    DGLCameraService dglCameraService;
    @Resource
    WorkPlace1GlueProcess workPlace1GlueProcess;
    @Override
    public void initProcessList() {
        processBeanList = dglProcessInitService.initWorkPace1(this);
    }

    @Override
    public void initHardware() {
        super.initHardware();
        desc = "工位一";
        initProcessList();
        workPlace1RobotInterface.initData();
        dglCameraService.initData();
        statusHolder.setAuto(true);
        workPlace1GlueProcess.initHardware();
        statusHolder.setOptInterface(new ChildOptImp(this){
            @Override
            public void stop() {
                workPlace1GlueProcess.statusHolder.stop();
            }

            @Override
            public void start() {
                if (!statusHolder.initComplete){
                    dglProcessInitService.startWorkPace1InitLocation(s -> {
                        statusHolder.initComplete = true;
                        statusHolder.start();
                    });
                }else{
                    if (workPlace1GlueProcess.statusHolder.process>0) {
                        workPlace1GlueProcess.statusHolder.start();
                    }
                }
            }
        });
    }
    public void startGlueProcess(){
        workPlace1GlueProcess.statusHolder.start();
    }


}
